<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%">importScripts(<span style="color: #BA2121">&#39;ffmpeg.js&#39;</span>);

<span style="color: #008000; font-weight: bold">function</span> print(text) {
  postMessage({
    <span style="color: #BA2121">&#39;type&#39;</span> <span style="color: #666666">:</span> <span style="color: #BA2121">&#39;stdout&#39;</span>,
    <span style="color: #BA2121">&#39;data&#39;</span> <span style="color: #666666">:</span> text
  });
}

onmessage <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">function</span>(event) {
  <span style="color: #008000; font-weight: bold">var</span> module <span style="color: #666666">=</span> {
    files<span style="color: #666666">:</span> event.data.files <span style="color: #666666">||</span> [],
    arguments<span style="color: #666666">:</span> event.data.arguments <span style="color: #666666">||</span> [],
    print<span style="color: #666666">:</span> print,
    printErr<span style="color: #666666">:</span> print
  };
  postMessage({
    <span style="color: #BA2121">&#39;type&#39;</span> <span style="color: #666666">:</span> <span style="color: #BA2121">&#39;start&#39;</span>,
    <span style="color: #BA2121">&#39;data&#39;</span> <span style="color: #666666">:</span> module.arguments
  });
  <span style="color: #008000; font-weight: bold">var</span> result <span style="color: #666666">=</span> ffmpeg_run(module);
  postMessage({
    <span style="color: #BA2121">&#39;type&#39;</span> <span style="color: #666666">:</span> <span style="color: #BA2121">&#39;done&#39;</span>,
    <span style="color: #BA2121">&#39;data&#39;</span> <span style="color: #666666">:</span> result
  });
};

postMessage({
  <span style="color: #BA2121">&#39;type&#39;</span> <span style="color: #666666">:</span> <span style="color: #BA2121">&#39;ready&#39;</span>
});
</pre></div>
